package com.yunxi.controller.otd;

import com.yunxi.otd.pojo.OtdOrderCirWeekImportVO;
import com.yunxi.otd.pojo.OtdOrderCirWeekQueryVO;
import com.yunxi.otd.pojo.OtdOrderCirWeekReleaseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.LoginInfo;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import com.yunxi.otd.service.OtdOrderCirWeekDubboService;
import com.yunxi.otd.pojo.OtdOrderCirWeekVO;

/**
 * <p>
 * 周CIR预测 前端控制器
 * </p>
 *
 * @author XUQI
 * @since 2019-10-14
 */
@RestController
@RequestMapping("/admin/cir/week")
@Api(tags = "OTD:CIRWEEK", description = "周CIR预测接口")
public class OtdOrderCirWeekController {

    private static final Logger logger = LoggerFactory.getLogger(OtdOrderCirWeekController.class);

    @Autowired
    OtdOrderCirWeekDubboService otdOrderCirWeekDubboService;

    @GetMapping("/page")
    @ApiOperation(value = "查询周CIR预测")
    public ApiResult page(OtdOrderCirWeekQueryVO queryVO) {
        if (StringUtils.isEmpty(queryVO.getYear())) {
            return ResponseUtil.fail(-1, "请选择年份");
        }
        if (StringUtils.isEmpty(queryVO.getWeek())) {
            return ResponseUtil.fail(-1, "请选择周数");
        }
        if (StringUtils.isEmpty(queryVO.getVersionId())) {
            return ResponseUtil.fail(-1, "请选择版本");
        }
        if (queryVO.getWeek().length() == 1) {
            queryVO.setWeek("0" + queryVO.getWeek());
        }
        return otdOrderCirWeekDubboService.page(queryVO);
    }

    @PostMapping("/import")
    @ApiOperation(value = "导入周预测")
    public ApiResult importData(@RequestBody OtdOrderCirWeekImportVO importVO) {
        return otdOrderCirWeekDubboService.importData(importVO);
    }

    @PostMapping("/modify")
    @ApiOperation(value = "修改数量")
    public ApiResult modify(@RequestBody OtdOrderCirWeekVO weekVO) {
        return otdOrderCirWeekDubboService.modify(weekVO);
    }

    @PostMapping("/release")
    @ApiOperation(value = "释放周预测")
    public ApiResult release(@RequestBody OtdOrderCirWeekReleaseVO releaseVO) {
        return otdOrderCirWeekDubboService.release(releaseVO);
    }


}
